/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.entity;


import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.field.FieldGenerator;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
import com.inspur.edp.cef.designtime.api.variable.CommonVariableEntity;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityDataImplGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.ValueObjectImplGenerator;
import com.inspur.edp.cef.generator.overall.GeneratorUtil;
import com.inspur.edp.cef.variable.api.variable.IVariable;
import com.inspur.edp.cef.variable.core.variable.AbstractVariable;
import com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.entity.cacheinfo.GetCacheInfoFieldGenerator;
import com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.entity.cacheinfo.GetCacheInfoMethodGenerator;
import com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.entity.data.VarDataImplGenerator;
import com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.entity.dtm.VarCreateAfterModifyDtmAssMethodGenerator;
import com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.entity.method.VarCtorGenerator;
import java.util.ArrayList;

public class VarImplGenerator extends ValueObjectImplGenerator
{
	private VarEntityGenCtx entityGenCtx;
	public VarImplGenerator(VarEntityGenCtx entityGenCtx, IGspCommonDataType node)
	{
		super(entityGenCtx, node);
		this.entityGenCtx = entityGenCtx;
		entityGenCtx.getProjContext().setRootEntityImplType(new MediateType(null, getName()));
	}

	@Override
	protected void addValueExtendParentInterfaces(ArrayList<TypeInfo> arrayList) {
		arrayList.add(new TypeInfo(IVariable.class));
		addImport(IVariable.class.getTypeName());
	}

	@Override
	protected Class getParentClass() {
		return AbstractVariable.class;
	}

	@Override
	protected String getName() {
		return dataType.getCode()+"entity";
	}

	@Override
	protected ClassMethodGenerator getCreateAfterCreateDtmAssMethodGenerator(){return null;}
	@Override
	protected ClassMethodGenerator getCreateAfterModifyDtmAssMethodGenerator()
	{
		return new VarCreateAfterModifyDtmAssMethodGenerator(getDataTypeImplContext(),getDataTypeImpContext().getNodeCode());
	}

	@Override
	protected ClassMethodGenerator getCreateAfterModifyValAssMethodGenerator(){return null;}
	@Override
	protected ClassMethodGenerator getCreateBeforeSaveDtmAssMethodGenerator(){return null;}
	@Override
	protected ClassMethodGenerator getCreateBeforeSaveValAssMethodGenerator(){return null;}

	@Override
	protected EntityDataImplGenerator getDataGenerator(MediateType baseType)
	{
		return new VarDataImplGenerator(entityGenCtx, dataType.getCode(), baseType);
	}
	@Override
	protected ClassMethodGenerator getConstructorGenerator(String typeName, String dataName)
	{
		return new VarCtorGenerator(typeName, dataName);
	}

	@Override
	protected FieldGenerator getDataTypeCacheInfoFieldGenerator() {
		return new GetCacheInfoFieldGenerator();
	}

	@Override
	protected ClassMethodGenerator getDataTypeCacheInfoMethodGenerator() {
		return new GetCacheInfoMethodGenerator();
	}

	@Override
	protected ArrayList<BaseGenerator> createClassExtendChildGenrators() {
		ArrayList<BaseGenerator> baseExtendGens = super.createClassExtendChildGenrators();
		if (baseExtendGens == null) {
			baseExtendGens = new ArrayList();
		}
//		baseExtendGens.add(new VariableDtmsGenerator(getDataTypeImplContext()));
//		baseExtendGens.add(new VariableValidationGenerator(getDataTypeImplContext()));
		return baseExtendGens;
	}
}
